﻿#include "loadlogthread.h"
#include <QMetaType>

LoadLogThread::LoadLogThread(QObject *parent) :
    QThread(parent)
{
    qRegisterMetaType<QVector<ResultManager::RESULT_DEF>> ("QVector<ResultManager::RESULT_DEF>");
	qRegisterMetaType<QMap<QString, ResultManager::DATE_RESULT_DEF>>("QMap<QString, ResultManager::DATE_RESULT_DEF>");
}

void LoadLogThread::SetLogFile(QString str, bool bByDate)
{
    m_fileName = str;
	m_bByDate = bByDate;
}

void LoadLogThread::run()
{
	
    ResultManager *r = ResultManager::getInstance();
	if (!m_bByDate)
	{
		QVector<ResultManager::RESULT_DEF> v = r->ParseLogFile(m_fileName);
		emit UpdateLogUI(v);
	}
	else
	{
		QMap<QString, ResultManager::DATE_RESULT_DEF> v = r->LogsByDate(m_fileName);
		emit UpdateDateUI(v);
	}

}
